<?php
namespace xcom\model;
use x\Xbase;
class Log extends Xbase
{
    //记录日志
    public function record($user_id, $msg, $tab='user'){
        $rs = $this->db->find($tab,$user_id,'username');
        $username = $rs?$rs['username']:'';
        $msg  = $username."于".date("Y-m-d H:i")."-".$msg;
        $data = [
            'user_id'           =>  $user_id,
            'tab' => $tab,
            'msg'               =>  $msg,
            'm'                 =>   $this->m,
            'c'                 =>   $this->c,
            'a'                 =>   $this->a,
            'ip'                =>   ip(),
            'create_time'       =>   time(),
        ];
        return $this->db->insert('log',$data);
    }
}
